package org.niux.aims.common.web;

import java.util.Locale;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.SessionAware;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class AimsBaseAction extends ActionSupport implements ServletRequestAware,SessionAware{

	/**
	 * 
	 */
	private static final long serialVersionUID = -1504364793742065108L;
	private Log log = LogFactory.getLog(this.getClass());
	
	private Map<String, Object> session;
	private HttpServletRequest request;
	
	public AimsBaseAction() {
		log.debug("初始化项目路径");
		ActionContext context = ActionContext.getContext();
		
		if(context != null){
			log.debug("初始化本地语言");
			context.getSession().put("WW_TRANS_I18N_LOCALE", new Locale(Locale.getDefault().getLanguage(), Locale.getDefault().getCountry()));
			HttpServletRequest request = (HttpServletRequest)ActionContext.getContext().get(org.apache.struts2.StrutsStatics.HTTP_REQUEST);
			request.setAttribute("ctx", request.getContextPath());
			log.debug(request.getContextPath());
		}
		
	}

	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	
	public Map<String, Object> getSession(){
		return this.session;
	}

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}
	
	public HttpServletRequest getRequest(){
		return this.request;
	}
}
